package jy.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import jy.model.Ftype;
import jy.pageModel.Json;
import jy.pageModel.PFood;
import jy.pageModel.PStore;
import jy.pageModel.PUser;
import jy.pageModel.SessionInfo;
import jy.service.StoreServiceI;
import jy.util.ConfigUtil;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/store")
public class StoreController extends BaseController {
	@Autowired
	private StoreServiceI storeService;
	
	@RequestMapping("/searchname")
	public String searchname(String keyword,HttpServletRequest request) {
		List<PStore> stores = storeService.searchname(keyword);
		request.setAttribute("stores",stores);
		return "/searchname";
	}
	
	
	@RequestMapping("/menu")	
	public String menu(String sid,HttpServletRequest request){
		PStore store = storeService.getInfo(sid);
		List<PFood> menu = storeService.menu(sid);
		request.setAttribute("store", store);
		request.setAttribute("menu", menu);
		return "/menu";
	}
	
	
	@RequestMapping("/addfood")	
	public String addFood(String sid,HttpServletRequest request){
		PStore store = storeService.getInfo(sid);
		store.setFtypes(storeService.getFtypes(sid));
		request.setAttribute("store", store);
		return "/store/manager/addfood";
	}
}
